"""Controller for current students."""

from mnemoply.controllers.lookup import TableLookupDataSource
from mnemoply.controllers.Customer import CustomerController, AgreementItemTab
from mnemoply.model.agreement import Customer
from mnemoply.controllers.lookup import LookupController, TableCol
from mnemoply.controllers.crud import CRUDController

class CustomerAndAgreementController(LookupController, CRUDController):
    """Controller for Customers."""
    model_object = Customer
    lookup_columns = [
        TableCol(name='id', caption=_("ID"),size=4),
        TableCol(name='customer', caption=_("Customer")),
        TableCol(name='student', caption=_("Student")),
        TableCol(name='agreement', caption=_("Agreements")),
        TableCol(name='office', caption=_("Office")),
        TableCol(name='groups', caption=_("Groups")),
        TableCol(name='amount_of_student', caption=_("Amount of students"),size=5),
        TableCol(name='amount_of_agreement', caption=_("Amount of agreement"),size=5),
        TableCol(name='phone_main', caption=_('Main phone'), hidden=True),
        TableCol(name='phones_more', caption=_('More phones'), hidden=True),
        ]
    def __init__(self):
        self.view_fields = CustomerController.view_fields
        self.edit_fields = CustomerController.edit_fields
        self.item_tabs = [AgreementItemTab()]

        LookupController.__init__(self,
            data_source=TableLookupDataSource('customer_and_agreement'),
            columns=self.lookup_columns,
            mass_actions_class=Customer,
        )
        CRUDController.__init__(self, model_object=self.model_object)
        self.title = _("Customer and agreement")
        self.local_menu = []
exposed = CustomerAndAgreementController()
